In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
Use scipy.integrate.quad
to integrate the function $f(x)=x$ over the range $[0,1]$.
In [ ]:
Check your answer by doing the integral analytically.
Define a Python function $f(x)$ that computes the value of the function:
$$ f(x) = x^2 + 2 x - 4 $$
In [ ]:
Use np.linspace
and plt.plot
to plot the function over a reasonable range that shows the minimum of the function:
In [ ]:
Use an appropriate function from scipy.optimize
to find the minimum of this function numerically. Make sure that the numerical answer makes sense.
In [ ]:
The following function has multiple minima:
$$ f(x) = 4x^3 + (x-2)^2 + x^4 $$Plot this function over the range $[-4,2]$ and find all of its minima using an appropriate function from scipy.optimize
.
In [ ]: